<?php	
	include('db_connection.php');

	class affiliate_login{
		function user_login(){
			if(trim($_POST['user_email']) != '' && trim($_POST['user_pwd']) != '') {
				$select_subscribe = "SELECT * FROM tbl_affiliate WHERE email_id='".$_POST['user_email']."' AND password='".md5($_POST['user_pwd'])."' AND is_active='1'";		
				$query_subscribe = mysql_query($select_subscribe) or die(mysql_error());

				$count_row_subscribe = mysql_num_rows($query_subscribe);
				if($count_row_subscribe>0){
					while($data_array = mysql_fetch_array($query_subscribe)){	
						
						$_SESSION['id'] = $data_array['id'];
						$_SESSION['user_name'] = $data_array['username'];
						$_SESSION['user_email'] = $data_array['email'];
						$_SESSION['user_reference_id'] = $data_array['reference_url'];
						//header('Location: dashboard/index.php?home=1');
						die("<script>location.href = 'dashboard/index.php?home=1".$set_eml_pwd."'</script>");
					}
				}else{
					return "Invalid Credentials";
				}
			}else{
				$val_msg = '';
				if(trim($_POST['user_email']) == '' && trim($_POST['user_pwd']) == ''){
					$val_msg = 'Email And Password Is Required';
				}else if(trim($_POST['user_email']) == ''){
					$val_msg = 'Email Is Required';
				}else if(trim($_POST['user_pwd']) == ''){
					$val_msg = 'Password Is Required';
				}
				return $val_msg;
			}
		}
	}
?>